package com.itheima.request1;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;

@WebServlet("/RequestServlet")
public class RequestServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取虚拟目录
        String contextPath = request.getContextPath();
        System.out.println(contextPath);
        //获取资源路径
        String servletPath = request.getServletPath();
        System.out.println(servletPath);
        //获取统一资源标识符
        String requestURI = request.getRequestURI();
        System.out.println(requestURI);
        //获取统一资源定位符
        StringBuffer requestURL = request.getRequestURL();
        System.out.println(requestURL);
        //获取浏览器IP地址
        String remoteAddr = request.getRemoteAddr();
        System.out.println(remoteAddr);
        //获取请求方式
        String method = request.getMethod();
        System.out.println(method);
        LinkedList<Integer> linkedList = new LinkedList();
        linkedList.add(1);
        linkedList.add(2);
        linkedList.add(3);
        linkedList.add(4);
        linkedList.add(5);
        linkedList.add(6);
        for (int i = 0; i < linkedList.size(); i++) {
            Integer integer = linkedList.get(i);
            System.out.println(integer);
        }
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);
        arrayList.add(5);
        for (int i = 0; i < arrayList.size(); i++) {
            
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
